﻿CREATE PROCEDURE [dbo].[ListTimeEntriesByProject]
@ProjectID INT, @StartDate DATETIME, @EndDate DATETIME
AS
SELECT e.EntryLogID,
	e.Description,
	e.Duration,
	e.OvernightStay,
	e.EntryDate,
	e.ProjectID,
	e.UserID,	
	e.CategoryID,
	c.Name AS CategoryName,
	u.FullName,
	u.UserName
FROM EntryLog e
	INNER JOIN Categories c ON e.CategoryID = c.CategoryID
	INNER JOIN Users u ON e.UserID = u.UserID
WHERE ProjectID = @ProjectID
	AND e.EntryDate BETWEEN @StartDate AND @EndDate
ORDER BY e.UserID, e.EntryDate

